# encoding: utf-8
from flask import redirect, url_for, request
from app.forms import *
from flask_login import login_required, current_user
from . import blog



@blog.route("/publish", methods=["POST", "GET"])
@login_required
def publish():
    """发布微博"""
    # 如果是get请求，则重定向到首页
    if request.method == "GET":
        return redirect(url_for("index"))
    form = BlogForm()
    # 新增记录
    form.publish(current_user)
    return redirect(url_for("index"))